package tool

import akka.actor.typed.ActorRef
import akka.actor.typed.receptionist.{Receptionist, ServiceKey}
import cluster.CborSerializable

/**
 * Created by yz on 30/9/2020
 */
object Pojo {

  trait MainCommand

  case object CreateChild extends MainCommand

  case class Response(msg: String, child: ActorRef[ChildCommand]) extends MainCommand

  case object FindChild extends MainCommand

  case object SayHi extends MainCommand

  case class GetValue(key: String, response: ActorRef[Object]) extends MainCommand with CborSerializable

  case class AdaptedResponse(msg: String) extends MainCommand

  case class Value(value: Object) extends ClientCommand with CborSerializable

  trait Reply


  trait ChildCommand

  case class Greeting(response: ActorRef[MainCommand]) extends ChildCommand

  case class LogTest(message: String) extends ClientCommand

  case class SetRequest(key: String, value: Object, main: ActorRef[ClientCommand]) extends ChildCommand with CborSerializable

  case class GetRequest(key: String, clientRef: ActorRef[ClientCommand]) extends ChildCommand with CborSerializable


  trait FindCommand

  case class SendMessage(key: ServiceKey[ChildCommand], command: ChildCommand) extends FindCommand

  case class ListingResponse(listing: Receptionist.Listing, command: ChildCommand) extends FindCommand

  sealed trait ClientCommand

  case class MyDbUpdated(myDbs: Receptionist.Listing) extends ClientCommand

  case object Tick extends ClientCommand

}
